package com.yuexunit.account.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Properties;

/**
 * @author kevis
 */
public class SMSConfig {
    public static final String CONFIG_FILE = "/sms.config.properties";
    public static final String SMS_URL = "sms.webservice.url";
    public static final String SMS_ACCOUNT = "sms.webservice.account";
    public static final String SMS_PASSWORD = "sms.webservice.password";
    public static final String SMS_CHANNEL = "sms.webservice.channel";
    public static final String SMS_AUTH = "sms.webservice.auth";
    public static final String SMS_REGISTER = "sms.webservice.template.register";
    public static final String SMS_FORGET = "sms.webservice.template.forgetpwd";
    public static final String SMS_CHANGE = "sms.webservice.template.changemobile";

    private static SMSConfig instance = new SMSConfig();
    private Properties props = null;

    public static SMSConfig getInstance() {
        return instance;
    }

    private SMSConfig() {
        try {
            props = new Properties();
            InputStreamReader readBuffer = new InputStreamReader(this.getClass().getResourceAsStream(CONFIG_FILE), "utf8");
            props.load(new BufferedReader(readBuffer));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public Properties getProps() {
        return props;
    }

    public String getProperty(String key) {
        return props.getProperty(key);
    }

    public String getProperty(String key, String defaultValue) {
        return props.getProperty(key, defaultValue);
    }
}
